﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MvcControlsToolkit
{
    public class TabItem: Container
    {
        public string Title { get; set; }
        public string Css { get; set; }
        public bool Selected { get; set; }
        public bool Enabled { get; set; }        
        
        public TabItem(string title): base(title)
        {
            Title = title;
            this.Enabled = true;
            this.Selected = false;
            this.ContentType = ContentType.Static;
            this.PartialViewName = null;
        }

        /// <summary>
        /// Set the content of the current Tb
        /// </summary>
        /// <param name="contentType">Determines how the content of the tab is to be rendered</param>
        /// <param name="name">If contentType is Static, determines the actual HTML, if contentType is PartialView, determines the view name, otherwise determines the action url</param>
        /// <param name="objectModel">Only when contentType is PartialView. The model to be passed to the view</param>
        /// <param name="viewData">Only when contentType is PartialView. The view data dictionary to be passed to the view</param>
        /// <returns></returns>
        public TabItem SetContent(ContentType contentType, string name, object objectModel = null, ViewDataDictionary viewData = null)
        {
            return base.SetContent(contentType, name, objectModel, viewData) as TabItem;
        }

        public override string ToString()
        {
            return GetHtml();
        }

        public override string GetJScript()
        {
            throw new NotImplementedException();
        }

        public override string GetHtml()
        {
            string css = (string.IsNullOrEmpty(this.Css)) ? "" : "class=\"" + this.Css + "\"";
            return string.Format("<li><a href=\"{0}\"><span {1}>{2}</span></a></li>\r\n", this.Action, css, this.Title);
        }
    }
}
